import numpy

# 0 阶张量
a = numpy.array(12)

print("0 阶张量：")
print(a)
print("维度数量：", a.ndim)

#
# 学习理解张量
#

# 1 阶张量
b = numpy.array([12, 9, 5, 42, 17])

print()
print()
print()

print("1 阶张量：")
print(b)
print("维度数量：", b.ndim)

# 2 阶张量
b = numpy.array([
                    [12, 9, 5, 42, 17],
                    [7, 79, 43, 2, 23],
                    [51, 18, 59, 11, 9]
                ])

print()
print()
print()

print("2 阶张量：")
print(b)
print("维度数量：", b.ndim)

# 3 阶张量
b = numpy.array([
                    [
                        [12, 9, 5, 42, 17],
                        [7, 79, 43, 2, 23],
                        [51, 18, 59, 11, 9]
                    ],
                    [
                        [22, 19, 15, 52, 27],
                        [17, 89, 53, 12, 33],
                        [61, 28, 69, 21, 19]
                    ],
                    [
                        [32, 39, 35, 72, 37],
                        [37, 9, 73, 32, 53],
                        [71, 48, 89, 41, 39]
                    ],
                    [
                        [42, 49, 45, 82, 47],
                        [47, 19, 93, 42, 63],
                        [81, 58, 99, 51, 49]
                    ]

                ])

print()

print("3 阶张量：")
print(b)
print("维度数量：", b.ndim)
